from django.db import models

# Create your models here.


class BookInfo(models.Model):
    name = models.CharField(max_length=10)
    pub_date = models.DateTimeField(verbose_name='发布日期',null=True)
    readcount = models.IntegerField(default=0,verbose_name='阅读量')
    commentcount = models.IntegerField(default=0,verbose_name='评论数')
    is_delete = models.BooleanField(default=False,verbose_name='逻辑删除')


    class Meta:
        db_table = 'bookinfo'
        verbose_name = '图书'

    def __str__(self):
        return self.name


class PeopleInfo(models.Model):
    GENDER_CHOICES = (
        (0, 'male'),
        (1, 'female')
    )
    name = models.CharField(max_length=10,verbose_name='人物名称')
    gender = models.BooleanField(default=0,choices=GENDER_CHOICES,verbose_name='性别')
    description = models.CharField(max_length=10,null=True,verbose_name='描述信息')
    is_delete = models.BooleanField(default=False,verbose_name='逻辑删除')
    book = models.ForeignKey(BookInfo, on_delete=models.CASCADE,verbose_name='图书信息')

    class Meta:
        db_table = 'peopleinfo'
        verbose_name = '人物信息'

    def __str__(self):
        return self.name


class Weapon(models.Model):
    name = models.CharField(max_length=10, verbose_name='武器名称')
    shanghaizhi = models.IntegerField(default=1, verbose_name='伤害值')
    is_delete = models.BooleanField(default=False, verbose_name='是否删除武器')

    class Meta:
        db_table = 'weapon'
        verbose_name = '武器信息'

    def __str__(self):
        return self.name


class Skill(models.Model):
        name = models.CharField(max_length=10, verbose_name='技能名称')
        hurt = models.IntegerField(default=1, verbose_name='伤害值')
        is_delete = models.BooleanField(default=False, verbose_name='是否删除技能')

        class Meta:
            db_table = 'skill'
            verbose_name = '技能信息'

        def __str__(self):
            return self.name

#class MyModel(models.Model):
#    my_foreign_key = models.ForeignKey(BookInfo, on_delete=models.CASCADE)
